<?php

namespace app\common\model;

use think\Db;
use think\Model;

/**
 * 短信验证码
 */
class FishingGroundFishs extends Model
{

    // 开启自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';
    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';

    protected $insert = ['status' => 1];
    // 追加属性
    protected $append = [
    ];

    public function getCreateTimeAttr($value)
    {
        return is_numeric($value) ? date('Y-m-d H:i:s', $value) : $value;
    }

    public function getUpdateTimeAttr($value)
    {
        return is_numeric($value) ? date('Y-m-d H:i:s', $value) : $value;
    }

    public function positions()
    {
        return $this->hasMany(FishingGroundPositions::class, 'id', 'fishs_id');
    }


    public function getimageAttr($value, $data)
    {
        $image = cdnurl($value,true);
        return $image;
    }


    public static function yu_id_name($id){
        $fish_typess = Db::name('config')->where('name','fish_types')->value('value');
        $fish_typess = json_decode($fish_typess,true);
    
        foreach($fish_typess as $k=>$v){
            if($id == $k){
                return $v;
            }
        }
     }
}
